package cn.wind.xboot.framework.interceptor;

import cn.wind.xboot.core.utils.SignUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * <p>Title: ParameterInterceptor</p>
 * <p>Description: TODO</p>
 *
 * @author xukk
 * @version 1.0
 * @date 2018/8/24
 */

@Component
@Slf4j
public class ParameterInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        if(request.getContentType()!=null&&MediaType.APPLICATION_FORM_URLENCODED.includes(MediaType.parseMediaType(request.getContentType()))){
            return SignUtil.verifySign("",request);
        }
        return true;
    }
}